import http from "@/common/http/request";
import {
  systemUserListInterface,
  systemUserAddInterface,
  systemUserUpdateInterface,
  systemUserChangeStatusInterface,
  systemUserResetPwdInterface,
} from "./user.interface";
// 用户列表
export const $systemUserList = (data: systemUserListInterface) => {
  const $http = new http();
  return $http.get({
    url: '/system/user/list',
    data,
  })
}

// 用户详情
export const $systemUserDetail = (userId: number) => {
  const $http = new http();
  return $http.get({
    url: `/system/user/${userId}`,
  })
}

// 新增用户
export const $systemUserAdd = (data: systemUserAddInterface) => {
  const $http = new http();
  return $http.post({
    url: '/system/user',
    data,
  })
}

// 修改用户
export const $systemUserUpdate = (data: systemUserUpdateInterface) => {
  const $http = new http();
  return $http.put({
    url: '/system/user',
    data,
  })
}

// 用户状态修改
export const $systemUserChangeStatus = (data: systemUserChangeStatusInterface) => {
  const $http = new http();
  return $http.put({
    url: '/system/user/changeStatus',
    data,
  })
}

// 删除用户
export const $systemUserDelete = (data: number[]) => {
  const $http = new http();
  return $http.delete({
    url: `/system/user/${data.join(',')}`,
  })
}

// 用户重置密码
export const $systemUserResetPwd = (data: systemUserResetPwdInterface) => {
  const $http = new http();
  return $http.put({
    url: `/system/user/resetPwd`,
    data,
  })
}